{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "获取前N个主成分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "X=np.empty((100,2))\n",
    "X[:,0]=np.random.uniform(0.,100.,size=100)\n",
    "X[:,1]=0.75*X[:,0]+3.+np.random.normal(0.,10.,size=100)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def demean(x):\n",
    "    return x-np.mean(x)\n",
    "X=demean(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAioAAAGdCAYAAAA8F1jjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA0N0lEQVR4nO3df5AU5b3v8c8ssrui7MCCMgssEYml2exFCgiyUTnRgHD1eE2kUif+OBVyuKhktVSsUomJhEqqEE1pDCGIlpLUQQPX/OKQGCJHrhiTJXjYEFkRcyV4giyzRJAZgu6P7Pb9Y+3Jzu786PnR3U/PvF9VVGVmemaebQz92ae/z/cJWZZlCQAAwEAVfg8AAAAgHYIKAAAwFkEFAAAYi6ACAACMRVABAADGIqgAAABjEVQAAICxCCoAAMBYZ/g9gEL19fWpvb1dI0eOVCgU8ns4AADAAcuydOrUKY0fP14VFennTQIfVNrb21VfX+/3MAAAQB4OHz6siRMnpn098EFl5MiRkvp/0JqaGp9HAwAAnIjH46qvr09cx9MJfFCxb/fU1NQQVAAACJhsZRsU0wIAAGMRVAAAgLEIKgAAwFgEFQAAYCzPgspDDz2kUCiku+66K/FcZ2enmpubNWbMGJ199tlauHChOjo6vBoSAAAwnCdB5bXXXtP69es1derUpOfvvvtubd26Vc8//7x27typ9vZ2XX/99V4MCQAABIDrQeVvf/ubbrrpJj311FMaPXp04vlYLKann35ajz76qK688krNmDFDGzZs0O9+9zvt2rXL7WEBAIAAcD2oNDc365prrtHcuXOTnt+zZ496enqSnr/ooos0adIktbS0pP28rq4uxePxpD8AAKA0udrwbdOmTWptbdVrr7025LVoNKrKykqNGjUq6flx48YpGo2m/cxVq1Zp5cqVxR4qAAAlq7fP0u5DJ3TsVKfOHVmtWZNrNawiGPvjuRZUDh8+rDvvvFPbt29XdXV10T53+fLlWrZsWeKx3YIXAAAMta3tqFZu3a+jsc7Ec3Xhaq24tkELGut8HJkzrt362bNnj44dO6bp06frjDPO0BlnnKGdO3fqu9/9rs444wyNGzdO3d3dOnnyZNL7Ojo6FIlE0n5uVVVVol0+bfMBAEhvW9tRLd3YmhRSJCka69TSja3a1nbUp5E551pQ+exnP6t9+/Zp7969iT8zZ87UTTfdlPjfw4cP10svvZR4z1tvvaW//OUvampqcmtYAACUhd4+Syu37peV4jX7uZVb96u3L9UR5nDt1s/IkSPV2NiY9NxZZ52lMWPGJJ5fvHixli1bptraWtXU1OiOO+5QU1OTZs+e7dawAAAoC7sPnRgykzKQJelorFO7D51Q05Qx3g0sR77unvzYY4+poqJCCxcuVFdXl+bPn6/vf//7fg4JAICScOxU+pCSz3F+8TSovPzyy0mPq6urtXbtWq1du9bLYQAAUPLOHelsIYvT4/zCXj8AAJSgWZNrVReuVrpFyCH1r/6ZNbnWy2HljKACAEAJGlYR0oprGyRpSFixH6+4tiFtP5XePkstB49ry94jajl43LeiW19rVAAAgHsWNNZp3c3Th/RRiWTpo2JS75WQZVlmr0vKIh6PKxwOKxaL0VMFAGA0vzrE5vK9du+VweHAPnrdzdOLElacXr+ZUQEAwAN+zlIMqwg5WoKcrfdKSP29V+Y1RDxrwU+NCgAALgtKh9hceq94haACAICLgtQ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LLVV1drfr6ej388MP+DDLg3nnnHS1evFiTJ0/WmWeeqSlTpmjFihXq7u5OOo7zXTxr167Veeedp+rqal1yySXavXu330MKvFWrVulTn/qURo4cqXPPPVef+9zn9NZbbyUd09nZqebmZo0ZM0Znn322Fi5cqI6ODp9GXDoeeughhUIh3XXXXYnnONfuIKgY6N5779X48eOHPB+Px3XVVVfpYx/7mPbs2aNHHnlE3/jGN/Tkk0/6MMpgO3DggPr6+rR+/Xq98cYbeuyxx/TEE0/oq1/9auIYznfxbN68WcuWLdOKFSvU2tqqiy++WPPnz9exY8f8Hlqg7dy5U83Nzdq1a5e2b9+unp4eXXXVVTp9+nTimLvvvltbt27V888/r507d6q9vV3XX3+9j6MOvtdee03r16/X1KlTk57nXLvEglFeeOEF66KLLrLeeOMNS5L1hz/8IfHa97//fWv06NFWV1dX4rn77rvPuvDCC30Yael5+OGHrcmTJycec76LZ9asWVZzc3PicW9vrzV+/Hhr1apVPo6q9Bw7dsySZO3cudOyLMs6efKkNXz4cOv5559PHPPmm29akqyWlha/hhlop06dsi644AJr+/bt1j/90z9Zd955p2VZnGs3MaNikI6ODi1ZskT//u//rhEjRgx5vaWlRXPmzFFlZWXiufnz5+utt97S+++/7+VQS1IsFlNtbW3iMee7OLq7u7Vnzx7NnTs38VxFRYXmzp2rlpYWH0dWemKxmCQl/jves2ePenp6ks79RRddpEmTJnHu89Tc3Kxrrrkm6ZxKnGs3EVQMYVmWFi1apNtuu00zZ85MeUw0GtW4ceOSnrMfR6NR18dYyt5++22tWbNGt956a+I5zndxvPfee+rt7U15LjmPxdPX16e77rpLl156qRobGyX1/3daWVmpUaNGJR3Luc/Ppk2b1NraqlWrVg15jXPtHoKKy+6//36FQqGMfw4cOKA1a9bo1KlTWr58ud9DDjSn53ugI0eOaMGCBfrCF76gJUuW+DRyoDDNzc1qa2vTpk2b/B5KSTp8+LDuvPNOPfvss6qurvZ7OGXlDL8HUOruueceLVq0KOMx559/vnbs2KGWlpYhe0XMnDlTN910k374wx8qEokMqSC3H0cikaKOO6icnm9be3u7rrjiCn36058eUiTL+S6OsWPHatiwYSnPJeexOG6//Xb94he/0CuvvKKJEycmno9EIuru7tbJkyeTftPn3Oduz549OnbsmKZPn554rre3V6+88oq+973v6de//jXn2i1+F8mg33//939b+/btS/z59a9/bUmyfvzjH1uHDx+2LOsfxZ3d3d2J9y1fvpzizjy9++671gUXXGB98YtftP7+978PeZ3zXTyzZs2ybr/99sTj3t5ea8KECRTTFqivr89qbm62xo8fb/3pT38a8rpd4PnjH/848dyBAwco8MxDPB5P+jd637591syZM62bb77Z2rdvH+faRQQVQx06dGjIqp+TJ09a48aNs/71X//VamtrszZt2mSNGDHCWr9+vX8DDah3333X+vjHP2599rOftd59913r6NGjiT82znfxbNq0yaqqqrJ+8IMfWPv377duueUWa9SoUVY0GvV7aIG2dOlSKxwOWy+//HLSf8MffPBB4pjbbrvNmjRpkrVjxw7rv/7rv6ympiarqanJx1GXjoGrfiyLc+0WgoqhUgUVy7KsP/7xj9Zll11mVVVVWRMmTLAeeughfwYYcBs2bLAkpfwzEOe7eNasWWNNmjTJqqystGbNmmXt2rXL7yEFXrr/hjds2JA45sMPP7S+8pWvWKNHj7ZGjBhhff7zn08K5Mjf4KDCuXZHyLIsy/P7TQAAAA6w6gcAABiLoAIAAIxFUAEAAMYiqAAAAGMRVAAAgLEIKgAAwFgEFQAAYCyCCgAAMBZBBQAAGIugAgAAjEVQAQAAxiKoAAAAY/1/4/6AjM0mPIIAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[:,0],X[:,1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "#函数部分\n",
    "def f(w,x):#目标函数（VAr）\n",
    "    return np.sum(x.dot(w)**2)/len(x)\n",
    "def df_math(w,x):#梯度函数\n",
    "    return x.T.dot(x.dot(w))*2./len(x)\n",
    "def direction(w):#计算单位向量\n",
    "    return w/np.linalg.norm(w)#向量/向量的模---->使其模长为1\n",
    "def first_component(x,initial_w,eta,n_iters=1e4,epsilon=1e-8):#梯度上升函数\n",
    "    w=direction(initial_w)#使初始向量为方向向量，模长为1\n",
    "    cur_iter=0\n",
    "    while cur_iter<n_iters:\n",
    "        gradient=df_math(w,x)\n",
    "        last_w=w\n",
    "        w=w+eta*gradient\n",
    "        w=direction(w)#向量转变成方向向量，模长为1\n",
    "        \n",
    "        if (abs(f(w,x)-f(last_w,x))<epsilon):\n",
    "            break\n",
    "        cur_iter+=1\n",
    "    return w"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.79142807, 0.61126231])"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "initial_w=np.random.random(X.shape[1])\n",
    "eta=0.01\n",
    "w=first_component(X,initial_w,eta)#找到第一主成分   \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "#第二主成分\n",
    "# X2=np.empty(X.shape)#初始化第二个主成分使其向量格式（行列）与原数据相同\n",
    "# for i in range(len(X)):\n",
    "#     \"\"\"所有数据减去第一主成分剩下的就是第二主成分【针对2维数据而言】\"\"\"\n",
    "#     X2[i]=X[i]-X[i].dot(w)*w#w是方向向量，X[i].dot(w)为|| X(i)project ||\n",
    "\"\"\"X.dot(w)为一维数组，需要通过reshape变成二维的矩阵\"\"\"\n",
    "X2=X-X.dot(w).reshape(-1,1)*w#向量化计算。X为(m,n),w为(n,)可以当成行列向量均可，X.dot(n).reshape(-1,1)为(m,1),最后乘以个w变成(m,n)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x1f70d8514f0>"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjMAAAGdCAYAAADnrPLBAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAxOUlEQVR4nO3df3yT9b338XcSaEOxDRZakipCAcXFWqTb2lXRM7VIAXvc5u3tj8HB3Y5p/TVBt8FRqJ2yop5bnVPBg06czB87jzPdXQ+yIeoRtdIzK9NSnMCCuNFSpaPhx9pCct1/dO0o/UGTJrlyJa/n45HHY0mu6+pnEci71/f7/XxthmEYAgAAsCi72QUAAAAMBWEGAABYGmEGAABYGmEGAABYGmEGAABYGmEGAABYGmEGAABYGmEGAABY2jCzCxiqYDCoPXv2KD09XTabzexyAADAIBiGoQMHDignJ0d2+9DurVg+zOzZs0fjxo0zuwwAABCGzz77TKeeeuqQrmH5MJOeni6p88PIyMgwuRoAADAYfr9f48aN6/4eHwrLh5muoaWMjAzCDAAAFhOJKSJMAAYAAJZGmAEAAJZGmAEAAJZGmAEAAJZGmAEAAJZGmAEAAJZGmAEAAJZGmAEAAJZm+aZ50RIIGqr1taj5QJuy050qzM2Uw87eTwAAxBvCTB/W1zeqsrpBja1t3a95XE5VlHlVmucxsTIAAHA8hpmOs76+UeVr63oEGUlqam1T+do6ra9vNKkyAADQF8LMMQJBQ5XVDTL6eK/rtcrqBgWCfR0BAADMQJg5Rq2vpdcdmWMZkhpb21Tra4ldUQAAYECEmWM0H+g/yIRzHAAAiD7CzDGy050RPQ4AAEQfYeYYhbmZ8ric6m8Btk2dq5oKczNjWRYAABgAYeYYDrtNFWVeSeoVaLqeV5R56TcDAEAcIcwcpzTPo5VzC+R29RxKcrucWjm3gD4zAADEGZrm9aE0z6MZXjcdgAEAsADCTD8cdpuKJ402uwwAAHACDDMBAAB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d75hdWsK74447VFZWpvHjx2vPnj2qqKiQw+HQ1VdfbXZpCefgwYM97nj5fD5t2bJFmZmZOu2003Tbbbfp3nvv1emnn67c3FwtXbpUOTk53SEfQzPQ55+ZmanKykpdfvnlcrvd2rlzp374wx9q8uTJmjlzZmg/aMjroSxu/vz5hqRejzfeeKP7mF27dhmzZs0yRowYYYwZM8a4/fbbjSNHjphXdIJ6//33jaKiIsPlchlOp9P40pe+ZPzkJz8x2trazC4tYf3sZz8zTjvtNCMlJcUoLCw03nvvPbNLSgpXXnml4fF4jJSUFOOUU04xrrzySmPHjh1ml5WQ3njjjT7/jZ8/f75hGJ3Ls5cuXWqMHTvWSE1NNS6++GLjj3/8o7lFJ5CBPv/Dhw8bl1xyiZGVlWUMHz7cGD9+vLFgwYIerVAGy2YYhjHU5AUAAGAW+swAAABLI8wAAABLI8wAAABLI8wAAABLI8wAAABLI8wAAABLI8wAAABLI8wAAABLI8wAAABLI8wAAABLI8wAAABLI8wAAABL+//pL8/4iqJkygAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X2[:,0],X2[:,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.8238203071674342e-06"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w2=first_component(X2,initial_w,eta)\n",
    "w2.dot(w)#w2和w1相互垂直，点乘接近0"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "封装求前N个主成分的方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "def first_n_component(n,X,eta=0.01,n_iters=1e4,epsilon=1e-8):\n",
    "    X_pca=X.copy()\n",
    "    X_pca=demean(X_pca)\n",
    "    res=[]#放置各个主成分的方向向量\n",
    "    for i in range(n):#遍历处理\n",
    "        initial_w=np.random.random(X_pca.shape[1])\n",
    "        w=first_component(X_pca,initial_w,eta)#求出当前主成分的方向向量\n",
    "        res.append(w)\n",
    "        X_pca=X_pca-X_pca.dot(w).reshape(-1,1)*w#迭代进入下一个主成分\n",
    "    return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[array([0.79142808, 0.6112623 ]), array([ 0.61126441, -0.79142645])]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "first_n_component(2,X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
